﻿Public Class xtf_LISTADOarticulorubro_

    Public Overrides Sub IniciarLista()
        Try
            gdc_general.BeginUpdate()
            gdc_general.DataSource = dtt_DataTable
            'ulg_Lista.DisplayLayout.GroupByBox.Style = Infragistics.Win.UltraWinGrid.GroupByBoxStyle.Full

            'Creacion y carga de Cuentas
            dtt_DataTable.Columns.Add("Identificador (ID)")
            dtt_DataTable.Columns.Add("Nombre")
            dtt_DataTable.Columns.Add("Descripción")
            dtt_DataTable.Columns.Add("I.V.A. %", GetType(Decimal))

            gdv_general.PopulateColumns(dtt_DataTable)

            gdv_general.Columns("I.V.A. %").AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far
            gdv_general.Columns("I.V.A. %").AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far

            Dim obj_ArticuloRubro_ As New cls_articulorubro_
            If obj_ArticuloRubro_.CargarTodos(ObtenerRegistroEstado) Then
                For Each ArticuloRubro As cls_articulorubro_ In obj_ArticuloRubro_.Items
                    AgregarItem(ArticuloRubro)
                Next
            End If
            'ulg_Lista.DataBind()

            FiltrarColumnas()
            gdc_general.EndUpdate()
        Catch ex As Exception
            'Dim frmError As New frm_ErrorManager(ex.Message)
        End Try
    End Sub

    Public Function AgregarItem(ByRef ArticuloRubro As cls_articulorubro_) As DataRow
        Dim Row As DataRow = dtt_DataTable.NewRow
        Row("Identificador (ID)") = ArticuloRubro.idarticulorubro
        Row("Nombre") = ArticuloRubro.nombre
        Row("Descripción") = ArticuloRubro.descripcion
        Row("I.V.A. %") = ArticuloRubro.iva

        dtt_DataTable.Rows.Add(Row)
        'ulg_Lista.Rows(ulg_Lista.Rows.Count - 1).Height = 19
        Return Row
    End Function

    Public Sub ModificarItem(ByRef ArticuloRubro As cls_articulorubro_, ByRef ulg_row As DataRow)
        ulg_row("Identificador (ID)") = ArticuloRubro.idarticulorubro
        ulg_row("Nombre") = ArticuloRubro.nombre
        ulg_row("Descripción") = ArticuloRubro.descripcion
        ulg_row("I.V.A. %") = ArticuloRubro.iva
    End Sub

    Public Sub New()

        Me.Cursor = Cursors.WaitCursor
        InitializeComponent()
        PERMISONuevo = "008005002"
        PERMISOModificar = "008005003"
        PERMISOEliminar = "008005004"
        PERMISOImprimir = "008005005"
        Me.Text = lbl_modulo.Text : lbl_modulodescripcion.Text = "Listado de " & lbl_modulo.Text & "."
        IniciarLista()
        Me.Cursor = Cursors.Default

    End Sub

End Class